﻿//-----------------------------------------------------------------------
// <copyright file="ProcessDataContract.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics.Silverlight.Contracts
{
    using System;

    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;

    using System.Runtime.Serialization;

    /// <summary>
    /// Defines the data contract representing the details of a process.
    /// </summary>
    [DataContract]
    public sealed class ProcessDataContract
    {
        #region public ProcessDataContract()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ProcessDataContract"/> class.
        /// </summary>
        public ProcessDataContract()
        {
            
        }

        #endregion

        #region public int BasePriority

        /// <summary>
        /// Gets the base priority of the associated process.
        /// </summary>
        /// <value>The base priority, which is computed from the <see cref="T:System.Diagnostics.Process.PriorityClass"/> of the associated process.</value>
        [DataMember]
        public int BasePriority
        {
            get;
            private set;
        }

        #endregion

        #region public int ExitCode

        /// <summary>
        /// Gets the value that the associated process specified when it terminated.
        /// </summary>
        /// <value>The code that the associated process specified when it terminated.</value>
        [DataMember]
        public int ExitCode
        {
            get;
            private set;
        }

        #endregion

        #region public int ExitTime

        /// <summary>
        /// Gets the time that the associated process exited.
        /// </summary>
        /// <value>A <see cref="T:System.DataTime"/> that indicates when the associated process was terminated.</value>
        [DataMember]
        public DateTime ExitTime
        {
            get;
            private set;
        }

        #endregion

        #region public int HandleCount

        /// <summary>
        /// Gets the number of handles opened by the process.
        /// </summary>
        /// <value>The number of operating system handles the process has opened.</value>
        [DataMember]
        public int HandleCount
        {
            get;
            private set;
        }

        #endregion

        #region public bool HasExited

        /// <summary>
        /// Gets a value indicating whether the associated process has been terminated.
        /// </summary>
        /// <value><c>true</c> if the operating system process referenced by the <see cref="T:System.Diagnostics.Process"/> component has terminated; otherwise, <c>false.</c></value>
        [DataMember]
        public bool HasExited
        {
            get;
            private set;
        }

        #endregion

        #region public int Id

        /// <summary>
        /// Gets the unique identifier for the associated process.
        /// </summary>
        /// <value>The system-generated unique identifier of the process that is referenced by this <see cref="T:System.Diagnostics.Process"/> instance.</value>
        [DataMember]
        public int Id
        {
            get;
            private set;
        }

        #endregion

        #region public string MachineName

        /// <summary>
        /// Gets the name of the computer the associated process is running on.
        /// </summary>
        /// <value>The name of the computer that the associated process is running on.</value>
        [DataMember]
        public string MachineName
        {
            get;
            private set;
        }

        #endregion

        #region public string MainModule

        /// <summary>
        /// Gets the name of the main module for the associated process.
        /// </summary>
        /// <value>The name of the <see cref="T:System.Diagnostics.ProcessModule"/> that was used to start the process.</value>
        [DataMember]
        public string MainModule
        {
            get;
            private set;
        }

        #endregion

        #region public string MainWindowTitle

        /// <summary>
        /// Gets the caption of the main window of the process.
        /// </summary>
        /// <value>The process's main window title.</value>
        [DataMember]
        public string MainWindowTitle
        {
            get;
            private set;
        }

        #endregion

        #region public IntPtr MaxWorkingSet

        /// <summary>
        /// Gets the maximum allowable working set size for the associated process.
        /// </summary>
        /// <value>The maximum working set size that is allowed in memory for the process, in bytes.</value>
        [DataMember]
        public IntPtr MaxWorkingSet
        {
            get;
            private set;
        }

        #endregion

        #region public IntPtr MinWorkingSet

        /// <summary>
        /// Gets the minimum allowable working set size for the associated process.
        /// </summary>
        /// <value>The minimum working set size that is allowed in memory for the process, in bytes.</value>
        [DataMember]
        public IntPtr MinWorkingSet
        {
            get;
            private set;
        }

        #endregion

        #region public long NonpagedSystemMemorySize64

        /// <summary>
        /// Gets the nonpaged system memory size allocated to this process.
        /// </summary>
        /// <value>The amount of memory the system has allocated for the associated process that cannot be written to the virtual memory paging file.</value>
        [DataMember]
        [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nonpaged", Justification = "Named according to the same naming and casing as in the System.Diagnostics.Process class.")]
        public long NonpagedSystemMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long PagedMemorySize64

        /// <summary>
        /// Gets the paged memory size.
        /// </summary>
        /// <value>The amount of memory allocated by the associated process that can be written to the virtual memory paging file.</value>
        [DataMember]
        public long PagedMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long PagedSystemMemorySize64

        /// <summary>
        /// Gets the amount of pageable system memory allocated for the associated process.
        /// </summary>
        /// <value>The amount of system memory, in bytes, allocated for the associated process that can be written to the virtual memory paging file.</value>
        [DataMember]
        public long PagedSystemMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long PeakPagedMemorySize64

        /// <summary>
        /// Gets the maximum amount of memory in the virtual memory paging file used by the associated process.
        /// </summary>
        /// <value>The maximum amount of memory, in bytes, allocated in the virtual memory paging file for the associated process since it was started.</value>
        [DataMember]
        public long PeakPagedMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long PeakVirtualMemorySize64

        /// <summary>
        /// Gets the maximum amount of virtual memory used by the associated process.
        /// </summary>
        /// <value>The maximum amount of virtual memory, in bytes, allocated for the associated process since it was started.</value>
        [DataMember]
        public long PeakVirtualMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long PeakWorkingSet64

        /// <summary>
        /// Gets the maximum amount of physical memory used by the associated process.
        /// </summary>
        /// <value>The maximum amount of physical memory, in bytes, allocated for the associated process since it was started.</value>
        [DataMember]
        public long PeakWorkingSet64
        {
            get;
            private set;
        }

        #endregion

        #region public bool PriorityBoostEnabled

        /// <summary>
        /// Gets a value indicating whether the associated process priority should temporarily be boosted by the operating system when the main window has the focus.
        /// </summary>
        /// <value><c>true</c> if dynamic boosting of the process priority should take place for a process when it is taken out of the wait state; otherwise, <c>false</c>. The default is <c>false</c>.</value>
        [DataMember]
        public bool PriorityBoostEnabled
        {
            get;
            private set;
        }

        #endregion

        #region public string PriorityClass

        /// <summary>
        /// Gets the overall priority category for the associated process.
        /// </summary>
        /// <value>The priority category for the associated process, from which the <see cref="T:System.Diagnostics.Process.BasePriority"/> of the process is calculated.</value>
        [DataMember]
        public string PriorityClass
        {
            get;
            private set;
        }

        #endregion

        #region public long PrivateMemorySize64

        /// <summary>
        /// Gets the amount of private memory allocated for the associated process.
        /// </summary>
        /// <value>The amount of memory, in bytes, allocated for the associated process that cannot be shared with other processes.</value>
        [DataMember]
        public long PrivateMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public TimeSpan PrivilegedProcessorTime

        /// <summary>
        /// Gets the privileged processor time for this process.
        /// </summary>
        /// <value>A <see cref="T:System.TimeSpan"/> that indicates the amount of time that the process has</value>
        [DataMember]
        public TimeSpan PrivilegedProcessorTime
        {
            get;
            private set;
        }

        #endregion

        #region public string ProcessName

        /// <summary>
        /// Gets the name of the process.
        /// </summary>
        /// <value>The name that the system uses to identify the process to the user.</value>
        [DataMember]
        public string ProcessName
        {
            get;
            private set;
        }

        #endregion

        #region public IntPtr ProcessorAffinity

        /// <summary>
        /// Gets the processors on which the threads in this process can be scheduled to run.
        /// </summary>
        /// <value>A bitmask representing the processors that the threads in the associated process can run on. The default depends on the number of processors on the computer. The default value is 2 n -1, where n is the number of processors.</value>
        [DataMember]
        public IntPtr ProcessorAffinity
        {
            get;
            private set;
        }

        #endregion

        #region public bool Responding

        /// <summary>
        /// Gets a value indicating whether the user interface of the process is responding.
        /// </summary>
        /// <value><c>true</c> if the user interface of the associated process is responding to the system; otherwise, <c>false</c>.</value>
        [DataMember]
        public bool Responding
        {
            get;
            private set;
        }

        #endregion

        #region public int SessionId

        /// <summary>
        /// Gets the Terminal Services session identifier for the associated process.
        /// </summary>
        /// <value>The Terminal Services session identifier for the associated process.</value>
        [DataMember]
        public int SessionId
        {
            get;
            private set;
        }

        #endregion

        #region public DateTime StartTime

        /// <summary>
        /// Gets the time that the associated process was started.
        /// </summary>
        /// <value>A <see cref="T:System.DateTime"/> that indicates when the process started. This only has meaning for started processes.</value>
        [DataMember]
        public DateTime StartTime
        {
            get;
            private set;
        }

        #endregion

        #region public int Threads

        /// <summary>
        ///  Gets the number of threads that are running in the associated process.
        /// </summary>
        /// <value>The number of threads that are running in the associated process.</value>
        [DataMember]
        public int Threads
        {
            get;
            private set;
        }

        #endregion

        #region public TimeSpan TotalProcessorTime

        /// <summary>
        /// Gets the total processor time for this process.
        /// </summary>
        /// <value>A <see cref="T:System.TimeSpan"/> that indicates the amount of time that the associated process has spent utilizing the CPU. This value is the sum of the <see cref="M:System.Diagnostics.Process.UserProcessorTime"/> and the <see cref="M:System.Diagnostics.Process.PrivilegedProcessorTime"/>.</value>
        [DataMember]
        public TimeSpan TotalProcessorTime
        {
            get;
            private set;
        }

        #endregion

        #region public TimeSpan UserProcessorTime

        /// <summary>
        /// Gets the user processor time for this process.
        /// </summary>
        /// <value>A <see cref="T:System.TimeSpan"/> that indicates the amount of user processor time for this process.</value>
        [DataMember]
        public TimeSpan UserProcessorTime
        {
            get;
            private set;
        }

        #endregion

        #region public long VirtualMemorySize64

        /// <summary>
        /// Gets the amount of the virtual memory allocated for the associated process.
        /// </summary>
        /// <value>The amount of virtual memory, in bytes, allocated for the associated process.</value>
        [DataMember]
        public long VirtualMemorySize64
        {
            get;
            private set;
        }

        #endregion

        #region public long WorkingSet64

        /// <summary>
        /// Gets the amount of physical memory allocated for the associated process.
        /// </summary>
        /// <value>The amount of physical memory, in bytes, allocated for the associated process.</value>
        [DataMember]
        public long WorkingSet64
        {
            get;
            private set;
        }

        #endregion
    }
}
